<template>
	<div class="alert" ref="alert">
		<div class="success" v-if="this.alertStatus==1">
			<p>{{alertText}}</p>
			<a class="submit" @click="alertSubmit">确定</a>
			<!--<a class="cancel" @click="alertCancel">取消</a>-->
		</div>
	</div>
</template>
<script>
	export default{
		data(){
			return{
				alertStatus:0,//0消失 1关闭
				alertText:'',
				submitTap:'',
				callBack: null, //是否需要回调函数
			}
		},
		methods:{
			//回调函数
			doCallBack() {
				if(typeof this.callBack == 'function') {
					this.callBack();
					this.callBack = null;
				}
			},
			alertSubmit(){
				this.submitTap();
				this.doCallBack();
				this.alertCancel();
			},
			alertCancel(){
				this.alertStatus=0;
				this.alertText='';
				this.callBack = null;
			},
			//显示弹窗，记性复制
			show(options) {
				this.submitTap=options.alertSubmit;
				if(this.alertStatus == 1) {
					return
				};
				this.alertText = options.alertText;
				this.alertStatus = 1;
				if(options.callBack) {
					this.callBack = options.callBack;
				}
			},
		}
	}
</script>